package com.zyz.I_多线程.线程通信;

/**
 * @author: vick
 * @Date: 2025/3/24
 * @Description:
 * @version: 1.0
 */
//生产者
public class Producer implements Runnable{
    private Storage storage;

    public Producer(Storage storage) {
        this.storage = storage;
    }


    @Override
    public void run() {
        System.out.println("===生产者开始生产===");
        while (true) {
            try {
                Thread.sleep(50);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            //生产完成，添加到仓库
            storage.addProduct();
        }
    }
}
